<?PHP
	require_once("AbstractController.php");
	
	class MainPageController extends AbstractController
	{
		public function processPage()
		{
			if(isset($_GET["section"]))
				$page = $_GET["section"];
			else
				$page = "index";
				
			$data_array = array();
			switch($page)
			{
				case "index":
				default:
					$data_array = $this->index();
				break;
			}
			
			$output = $this->createOutput($data_array);
			echo $output;
		}
		
		private function index()
		{
			$data_array = array();
			$user = $this->getLoggedUser();
			if($user === NULL)
				$data_array["logged_user"] = false;
			else
			{
				$data_array["logged_user"] = true;
				$data_array["logged_user_username"] = $user->login;
				$data_array["logged_user_id"] = $user->id;
			}
			ob_start();
			
			echo "Dane. Tutaj będą dane!";
			//...
			
			$output = ob_get_contents();
			ob_end_clean();
			$data_array["content"] = $output;
			return $data_array;
		}
	}
	
	$controller = new MainPageController();
	$controller->processPage();
	
	/*
	$SQL_Handle = new SQL();
	
	if($array = $SQL_Handle->query("SELECT * from baza where premium = 1;"))
	{
		while($row = mysqli_fetch_assoc($array))
		{
			echo($row['name']."<br />");
		}
		
	}

	$time = microtime_float();
	ob_start();
	
	include(PATH."templates/demoty/index.php");
	$data_array = array("logged_user"=>true, "logged_user_username" => "QuaS", "logged_user_id"=>10);
	$output = ob_get_contents();
	$output = preg_replace("/\{\{([A-Za-z0-9_\-]+)\}\}/e", "replaceTag('$1',\$data_array )", $output);
	$output = evalConditionTags($output , $data_array);
	
	ob_end_clean();
	$time = round(microtime_float() - $time,5);
	
	$data_array["footer_loading_time"] = $time;
	$output = preg_replace("/\{\{([A-Za-z0-9_\-]+)\}\}/e", "replaceTag('$1',\$data_array )", $output);
	echo($output);*/
	
	
	
?>